package com.lywz.biz.dao.food.impl;

import java.util.List;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import com.lywz.biz.common.dao.AbstractBaseDao;
import com.lywz.biz.common.entity.goodfood.ClassicFood;
import com.lywz.biz.dao.food.ClassicFoodDao;
import com.lywz.core.util.CommonDefaultCheck;

/**
 * @author qianqi yangbolin
 * @date 2010-5-4
 */
@Repository("classicFoodDao")
public class ClassicFoodDaoImpl extends AbstractBaseDao implements ClassicFoodDao {

    @SuppressWarnings("unchecked")
    @Override
    public List<ClassicFood> getTopTenClassicFoodList(int limit) throws Exception {
        Query query = session().getNamedQuery("classicFood.topTenList");
        //        getHibernateTemplate();
        query.setFirstResult(0);
        query.setMaxResults(10);
        return (List<ClassicFood>)CommonDefaultCheck.checkDefault(query.list());
    }

    @SuppressWarnings("unchecked")
    @Override
    public List<ClassicFood> getClassicFoodListOrderByPower()throws Exception {
        Query query = session().getNamedQuery("classicFood.getAllClassicFoodList");
        return (List<ClassicFood>) CommonDefaultCheck.checkDefault(query.list());
    }

    //    @Override
    //    public ClassicFood getOneClassicFoodById(int classicFoodId) throws Exception {
    //        Query query = session().getNamedQuery("classicFood.queryById");
    //        query.setParameter("classicFoodId", classicFoodId);
    //        return null;
    //    }

}
